//
// Copyright (c) 2009-2011, chunquedong
//
// This file is part of ChunMap project
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
//
// History:
//   2011-09-04  Jed Young  Creation
//

using gfx2
using chunmapData
using chunmapModel

@Js
class GTile : Tile, Raster
{
  private GDataSource? datasource

  new make(Int x, Int y, Int z) : super(x, y, z)
  {
  }

  Void setDataSource(GDataSource datasource)
  {
    this.datasource = datasource
    if(proxy!=null){
      proxy.datasource=datasource
    }
  }

  override Envelope envelope() { datasource.getEnvelope(this) }

  override Image2? image() { datasource.getImage(this) }

  override Obj? id() { toStr }

//////////////////////////////////////////////////////////////////////////
// proxy
//////////////////////////////////////////////////////////////////////////

  GTile? proxy

  Void createProxy()
  {
    if (proxy == null)
    {
      proxy = GTile(x,y,z)
    }
  }
}